<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>
// 模拟action调用过程
// 不封装promise
/*
function filterRoutes(){
  return [1,2,3]
}

function dispatch(name){
  return filterRoutes()
}

const list = dispatch('filterRoutes')
console.log(list)
*/
// 封装promise
function filterRoutes(){
  return [1,2,3]
}

function dispatch(name){
  let p = new Promise((resolve, reject)=>{
    let result = filterRoutes()
    resolve(result)
  })
  return p
}

async function fn(params) {
  const list = await dispatch('filterRoutes') //[1,2,3] 还是 promise
  console.log(list)  //promise

}

fn()
</script>
</html>
